package com.company.OfferGuide;

import com.company.ListNode;

/**
 * @author jrue
 * @version 1.0
 * @date 2020/3/23 10:28
 */
public class 链表的中间结点 {

    public ListNode middleNode(ListNode head) {
        if (head == null) return head;
        ListNode p = head,q = head;

        while (p != null && q.next != null) {
            p = p.next;
            q = q.next.next;
        }

        return p;
    }

}
